/**
 * Created: 	Jul.2-2011
 * By:			eeorange
 * Question:	zoj1028 - Flip and Shift
 * Status:		Accept
 */
 
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int nr_cases;
    cin >> nr_cases;
    while(nr_cases--){
        int n;
        cin >> n;
        if(n%2 == 1){	// if n is odd 
            int t;
            while(n--) cin >> t;
            cout << "YES\n";
    	}
    	else{
            int a = 0, b = 0;
			for(int i=0; i<n; i++){
	            int t;
	            cin >> t;
	            if(t) (i%2 == 1) ? a++ : b++;
			}
			if(abs(a-b) <= 1) cout << "YES\n";	// Compare 1s count in odd and even
			else cout << "NO\n";
		}
	}
	#ifdef LOCAL
		system("pause");
	#endif	
	return 0;
}

        
            
